/*

Frequency of use: 1 2 [3] 4 5 MEDIUM

Short:
    State is like an enum, but we can define different behaviour for each state. 
We could add another class, Sad, which did something entirely different when 
asked to talk().

Long:
    The state pattern is a behavioral software design pattern, also known as the 
objects for states pattern. This pattern is used in computer programming to 
represent the state of an object. This is a clean way for an object to partially 
change its type at runtime.

Information sources:
 - http://calumgrant.net/patterns/index.html
 - http://en.wikipedia.org/wiki/State_pattern
 - http://www.dofactory.com/Patterns/Patterns.aspx
*/

#include <iostream>

class Mood
{
public:
	virtual ~Mood() { }
	virtual void talk()=0;
};

class Happy : public Mood
{
public:
	void talk() { std::cout << "Hello world!" << std::endl; }
};

void hello_world(Mood & mood)
{
	mood.talk();
}

int main()
{
	Happy mood;
	hello_world(mood);
	return 0;
}

